package com.example.multitenant

import com.example.multitenant.model.Persons
import com.example.multitenant.multitenant.config.TenantContext
import com.example.multitenant.multitenant.controller.TenantController
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class MultiTenantApplicationTests {

    @Autowired
    private lateinit var controller: TenantController

    @Autowired
    private lateinit var persons: Persons

    @Test
    fun contextLoads() {

        TenantContext.setTenantId("tenant1")
        controller.addPerson("Peter")
        println(persons.findAll())

        TenantContext.setTenantId("tenant2")
        controller.addPerson("Ross")
        println(persons.findAll())

    }

}
